package com.jinzhi.jzweb.controller;

import com.jinzhi.jzweb.domain.JazSignupTeamDO;
import com.jinzhi.jzweb.domain.JazSignupUserDO;
import com.jinzhi.jzweb.service.JazSignupTeamService;
import jodd.util.StringUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * 队伍管理页面
 */
@Controller
@RequestMapping("/team")
public class TeamController {
    @Autowired
    private JazSignupTeamService jazSignupTeamService;
    @GetMapping("/list")
    @RequiresPermissions("team:list:list")
    String index(){
        return "jzweb/team/index";
    }
    @GetMapping("/info/{id}")
    String infor(@PathVariable("id") Long id, Model model) {
        model.addAttribute("id", id);
        JazSignupTeamDO myData=jazSignupTeamService.getById(id).getData();
        model.addAttribute("myData",myData);
        model.addAttribute("mapKey",null==myData.getMap()?new String[0]:myData.getMap().keySet());
        model.addAttribute("applyForms",!StringUtil.isNotEmpty(myData.getJazSignupUserDO().getApplyForm()) ?new String[0]:myData.getJazSignupUserDO().getApplyForm().split(",")  );
        return "jzweb/team/infor";
    }
}

